@extends('layouts.master')
@section('content') 
<?php 
	session_start();
	$_SESSION['isLoggedIn'] = true; 
?>
<script src="{{ asset('assets/tinymce/tinymce.min.js')}}"></script>
<script src="/upload/js/moxman.loader.min.js"></script>

   <div class="row">
	<div id="breadcrumb" class="col-md-12">
		<ol class="breadcrumb">
			<li><a href="{{Config::get('config.domain')}}dashboard">Dashboard</a></li>			
			<li><a href="{{Config::get('config.domain')}}news">News</a></li>
			
		</ol>
	</div>
</div>
<div class="row">
	<div class="col-xs-12 col-sm-12">
		<div class="box">
			
			<div class="box-content">
				<form id="categoryForm" method="post"  class="form-horizontal">
					<fieldset>
						<!-- >div class="form-group">
							<label class="col-sm-3 control-label">Language <span class="note">*</span></label>
							<div class="col-sm-5">
								<select class="populate placeholder form-control" name="languge" 
								 	 id = "languge"
		                            data-rule-required="true"
		                            data-msg-required="Please select a languge !">
									<option value="">-- Select a language --</option>
									<option value="1">France</option>
									<option value="2">Germany</option>
									
								</select>
							</div>
						</div -->

						<div class="form-group">
							<label class="col-sm-3 control-label">Category <span class="note">*</span></label>
							<div class="col-sm-5">
								<select class="populate placeholder form-control" name="categoryID" 
								 	 id = "category"
		                            data-rule-required="true"
		                            data-msg-required="Please select a category !">
									<option value="">-- Select a category --</option>
									@foreach($listCategory as $key=>$cat)
									<option value="{{$key}}" @if($dataEdit->categoryID==$key) selected="true" @endif>{{$cat}}</option>									
									 @endforeach
									
								</select>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">Upload Feature Photo</label>
							<div class="col-sm-5">
								<a class="btn" onclick="moxman.browse({view: 'thumbs', fields: 'urlimg', extensions:'jpg,gif,png'});" href="javascript:;">Pick file</a>
								<input id="urlimg" class="form-control" type="hidden" name="featurePhoto">
								<div id="succ">								
									<?php if($dataEdit->featurePhoto!=""){ ?>								
									<img class='img-thumbnail'  style="width:150px; height: 150px;" src="{{$dataEdit->featurePhoto}}">
									<?php }?>
								</div>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">Title <span class="note">*</span></label>
							<div class="col-sm-5">
								<input type="text" class="form-control" name="title" value="{{$dataEdit->title}}"
		                            id = "title"
		                            data-rule-required="true"
		                            data-msg-required="Please enter news title !"
		                        />
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">Description <span class="note">*</span></label>
							<div class="col-sm-5">
								<textarea class="form-control" rows="3" id="wysiwig_simple" name="description">{{$dataEdit->description}}</textarea>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">Status</label>
							<div class="col-sm-5">
								<select class="populate placeholder form-control" name="status" id="s2_country">
									
									@foreach($allStatus as $key=>$stauts)
									<option value="{{$key}}" @if($dataEdit->status==$key) selected="true" @endif>{{$stauts}}</option>									
									 @endforeach
									
								</select>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label" data-rule-required="true"
		                            data-msg-required="Please enter news content!">Content <span class="note">*</span></label>
							
						</div>
						<div class="form-group">							
							<div class="col-sm-12">
								<!-- >textarea class="ckeditor" id="wysiwig_simple" name="content"></textarea -->
								<textarea id="absurls" name="content" cols="85" rows="15">{{$dataEdit->content}}</textarea>
								
							</div>
						</div>
						
						
					</fieldset>					
					
					<div class="form-group">
						<div class="col-sm-9 col-sm-offset-3">
							<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
							<button type="submit" class="btn btn-primary">Submit</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
	
</div>
<script type="text/javascript">
    var $form = $("#categoryForm");
    $form.validate();
    $form.submit(function (event) {
    });
    tinymce.init({
        selector: '#absurls',       
        relative_urls: false,       
        plugins:["moxiemanager link image","advlist autolink lists charmap print preview anchor","searchreplace visualblocks code fullscreen","insertdatetime media table contextmenu paste moxiemanager"],
        toolbar:"undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image media insertfile moxiemanager",
    	external_plugins: {
    		"moxiemanager": "/upload/plugin.min.js"
    	}       
    });

    $("#urlimg").change(function(){
		var url_img=$("#urlimg").val();
	
		if(url_img.length>0){
			var src_img = "<img  style='widht:150px;height:150px;'class='img-thumbnail' src="+url_img +" >";
			$('div#succ').fadeIn(); 
            $('div#succ').html(src_img);
		}
	});
    
</script>


@stop

